package com.tbs.easyhomemoneyserver.model.dto

import com.fasterxml.jackson.annotation.JsonFormat
import com.tbs.easyhomemoneyserver.constants.CommonConstants
import java.io.Serializable
import java.util.*

data class FlowNodeDTO(
    var nodeId: Long? = null,
    var templateItemId: Long? = null,
    var templateId: Long? = null,
    var flowName: String? = null,
    var flowIndex: Int? = null,
    var maxFlowIndex: Int? = null,
    var flowType: String? = null,
    var numberArg: Int? = null,
    var textArg: String? = null,
    var intValue: Int? = null,
    var textValue: String? = null,

    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_yyyyMMddHHmmss)
    var intValueEditTime: Date? = null,

    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_yyyyMMddHHmmss)
    var textValueEditTime: Date? = null,

    var intValueEditor: Long? = null,

    var textValueEditor: Long? = null,

    var note: String? = null,

    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_yyyyMMddHHmmss)
    var createTime: Date? = null,

    var parentNode: Long? = null,

    var status: Byte? = null,

    var beginNode: Long? = null,

    var nodeParams: String? = null,

    var nodeParamType: String? = null
) : Serializable {
    companion object {
        private const val serialVersionUID = 2999009856292231527L
        const val BASIC_SQL: String = "SELECT\n" +
                "\tfn.id node_id,\n" +
                "\tfn.begin_node,\n" +
                "\tfn.create_time,\n" +
                "\tfn.int_value,\n" +
                "\tfn.int_value_edit_time,\n" +
                "\tfn.int_value_editor,\n" +
                "\tfn.node_param_type,\n" +
                "\tfn.node_params,\n" +
                "\tfn.note,\n" +
                "\tfn.parent_node,\n" +
                "\tft.id template_id,\n" +
                "\tfn.template_item_id,\n" +
                "\tfn.`status`,\n" +
                "\tfn.text_value,\n" +
                "\tfn.text_value_editor,\n" +
                "\tfn.text_value_edit_time,\n" +
                "\tfn.flow_type,\n" +
                "\tfti.flow_index,\n" +
                "\tfti.flow_name,\n" +
                "\tfti.number_arg,\n" +
                "\tfti.text_arg,\n" +
                "\t( SELECT max( flow_index ) FROM flow_template_item WHERE id = ft.id ) max_flow_index \n" +
                "FROM\n" +
                "\tflow_template ft\n" +
                "\tLEFT JOIN flow_template_item fti ON fti.id = ft.id\n" +
                "\tLEFT JOIN flow_node fn ON fn.template_item_id = fti.id"

    }
}
